package cn.jjxx.modules.record.entity;

import cn.jjxx.core.common.entity.AbstractEntity;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.framework.superutil.thirdparty.excel.Excel;
import cn.jjxx.modules.sys.entity.User;

import java.lang.reflect.Field;
import java.util.*;

/**   
 * @Title: 党组织
 * @Description: 党组织
 * @author zx
 * @date 2021-01-04 13:32:02
 * @version V1.0   
 *
 */
@TableName("party_organization")
@SuppressWarnings("serial")
public class PartyOrganization extends AbstractEntity<String> {

    /**字段主键*/
    @Excel(name="字段主键")
    @TableId(value = "id", type = IdType.UUID)
	private String id;
    /**组织Id*/
    @Excel(name="组织Id")
    @TableField(value = "org_id")
	private String orgId;
    /**状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）*/
    @Excel(name="状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）")
    @TableField(value = "status")
	private Integer status;
    /**创建者*/
    @Excel(name="创建者")
    @TableField(value = "create_by",el="createBy.id",fill = FieldFill.INSERT)
	private User createBy;
    /**创建时间*/
    @Excel(name="创建时间")
    @TableField(value = "create_date",fill = FieldFill.INSERT)
	private Date createDate;
    /**更新者*/
    @Excel(name="更新者")
    @TableField(value = "update_by",el="updateBy.id",fill = FieldFill.UPDATE)
	private User updateBy;
    /**更新时间*/
    @Excel(name="更新时间")
    @TableField(value = "update_date",fill = FieldFill.UPDATE)
	private Date updateDate;
    /**删除标记（0：正常；1：删除）*/
    @Excel(name="删除标记（0：正常；1：删除）")
    @TableField(value = "del_flag")
	private String delFlag;
    /**备注信息*/
    @Excel(name="备注信息")
    @TableField(value = "remarks")
	private String remarks;
    /**党委*/
    @Excel(name="党委")
    @TableField(value = "party_committee")
	private String partyCommittee;
    /**党总支*/
    @Excel(name="党总支")
    @TableField(value = "party_general")
	private String partyGeneral;
    /**党支部*/
    @Excel(name="党支部")
    @TableField(value = "party_branch")
	private String partyBranch;
    /**联合党支部*/
    @Excel(name="联合党支部")
    @TableField(value = "united_party")
	private String unitedParty;
    /**临时党支部*/
    @Excel(name="临时党支部")
    @TableField(value = "temporary_party")
	private String temporaryParty;
    /**更新时间*/
    @Excel(name="更新时间")
    @TableField(value = "update_time")
	private String updateTime;


    public static PartyOrganization fromObject(Object obj){
    	PartyOrganization entity = new PartyOrganization();
		BiMap<String,String> protocol = HashBiMap.create();
		protocol.put("partyCommittee","党委");
		protocol.put("partyGeneral","党总支");
		protocol.put("partyBranch","党支部");
		protocol.put("unitedParty","联合党支部");
		protocol.put("temporaryParty","临时党支部");
		protocol = protocol.inverse();
		List<Object> list = (List<Object>)obj;
		for(Object o :list){
			Map<String,String> map = (Map<String,String>)o;
			String label = map.get("label");
			String filed = protocol.get(label);
			if(filed!=null){
				try {
					Field f = entity.getClass().getDeclaredField(filed);
					f.setAccessible(true);
					f.set(entity,String.valueOf(map.get("count")));
				} catch (NoSuchFieldException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
			}
		}
    	return entity;
	}

	public List<Map<String,Object>> toJsonObject(){
		List<Map<String,Object>> obj = new ArrayList<>();
		BiMap<String,String> protocol = HashBiMap.create();
		protocol.put("partyCommittee","党委");
		protocol.put("partyGeneral","党总支");
		protocol.put("partyBranch","党支部");

//		protocol.put("unitedParty","联合党支部");
//		protocol.put("temporaryParty","临时党支部");
		for(String filedName : protocol.keySet()){
			try {
				Field field = getClass().getDeclaredField(filedName);
				String value = field.get(this).toString();
				Map<String,Object> map = new HashMap<>();
				map.put("count",Integer.parseInt(value));
				map.put("label",protocol.get(filedName));
				obj.add(map);
			} catch (NoSuchFieldException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return obj;
	}
	
	/**
	 * 获取  id
	 *@return: String  字段主键
	 */
	public String getId(){
		return this.id;
	}

	/**
	 * 设置  id
	 *@param: id  字段主键
	 */
	public void setId(String id){
		this.id = id;
	}
	/**
	 * 获取  orgId
	 *@return: String  组织Id
	 */
	public String getOrgId(){
		return this.orgId;
	}

	/**
	 * 设置  orgId
	 *@param: orgId  组织Id
	 */
	public void setOrgId(String orgId){
		this.orgId = orgId;
	}
	/**
	 * 获取  status
	 *@return: Integer  状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）
	 */
	public Integer getStatus(){
		return this.status;
	}

	/**
	 * 设置  status
	 *@param: status  状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）
	 */
	public void setStatus(Integer status){
		this.status = status;
	}
	/**
	 * 获取  createBy
	 *@return: User  创建者
	 */
	public User getCreateBy(){
		return this.createBy;
	}

	/**
	 * 设置  createBy
	 *@param: createBy  创建者
	 */
	public void setCreateBy(User createBy){
		this.createBy = createBy;
	}
	/**
	 * 获取  createDate
	 *@return: Date  创建时间
	 */
	public Date getCreateDate(){
		return this.createDate;
	}

	/**
	 * 设置  createDate
	 *@param: createDate  创建时间
	 */
	public void setCreateDate(Date createDate){
		this.createDate = createDate;
	}
	/**
	 * 获取  updateBy
	 *@return: User  更新者
	 */
	public User getUpdateBy(){
		return this.updateBy;
	}

	/**
	 * 设置  updateBy
	 *@param: updateBy  更新者
	 */
	public void setUpdateBy(User updateBy){
		this.updateBy = updateBy;
	}
	/**
	 * 获取  updateDate
	 *@return: Date  更新时间
	 */
	public Date getUpdateDate(){
		return this.updateDate;
	}

	/**
	 * 设置  updateDate
	 *@param: updateDate  更新时间
	 */
	public void setUpdateDate(Date updateDate){
		this.updateDate = updateDate;
	}
	/**
	 * 获取  delFlag
	 *@return: String  删除标记（0：正常；1：删除）
	 */
	public String getDelFlag(){
		return this.delFlag;
	}

	/**
	 * 设置  delFlag
	 *@param: delFlag  删除标记（0：正常；1：删除）
	 */
	public void setDelFlag(String delFlag){
		this.delFlag = delFlag;
	}
	/**
	 * 获取  remarks
	 *@return: String  备注信息
	 */
	public String getRemarks(){
		return this.remarks;
	}

	/**
	 * 设置  remarks
	 *@param: remarks  备注信息
	 */
	public void setRemarks(String remarks){
		this.remarks = remarks;
	}
	/**
	 * 获取  partyCommittee
	 *@return: String  党委
	 */
	public String getPartyCommittee(){
		return this.partyCommittee;
	}

	/**
	 * 设置  partyCommittee
	 *@param: partyCommittee  党委
	 */
	public void setPartyCommittee(String partyCommittee){
		this.partyCommittee = partyCommittee;
	}
	/**
	 * 获取  partyGeneral
	 *@return: String  党总支
	 */
	public String getPartyGeneral(){
		return this.partyGeneral;
	}

	/**
	 * 设置  partyGeneral
	 *@param: partyGeneral  党总支
	 */
	public void setPartyGeneral(String partyGeneral){
		this.partyGeneral = partyGeneral;
	}
	/**
	 * 获取  partyBranch
	 *@return: String  党支部
	 */
	public String getPartyBranch(){
		return this.partyBranch;
	}

	/**
	 * 设置  partyBranch
	 *@param: partyBranch  党支部
	 */
	public void setPartyBranch(String partyBranch){
		this.partyBranch = partyBranch;
	}
	/**
	 * 获取  unitedParty
	 *@return: String  联合党支部
	 */
	public String getUnitedParty(){
		return this.unitedParty;
	}

	/**
	 * 设置  unitedParty
	 *@param: unitedParty  联合党支部
	 */
	public void setUnitedParty(String unitedParty){
		this.unitedParty = unitedParty;
	}
	/**
	 * 获取  temporaryParty
	 *@return: String  临时党支部
	 */
	public String getTemporaryParty(){
		return this.temporaryParty;
	}

	/**
	 * 设置  temporaryParty
	 *@param: temporaryParty  临时党支部
	 */
	public void setTemporaryParty(String temporaryParty){
		this.temporaryParty = temporaryParty;
	}
	/**
	 * 获取  updateTime
	 *@return: String  更新时间
	 */
	public String getUpdateTime(){
		return this.updateTime;
	}

	/**
	 * 设置  updateTime
	 *@param: updateTime  更新时间
	 */
	public void setUpdateTime(String updateTime){
		this.updateTime = updateTime;
	}
	
}
